﻿using System;
using LibraryGuard.Interfaces;
using LibraryGuard.Interfaces.Configuration;

namespace LibraryGuard.Modes
{
	/// <summary>
	/// Factory for modes.
	/// </summary>
	public static class Factory
	{
		/// <summary>
		/// Creates mode based on configuration.
		/// </summary>
		/// <param name="config"></param>
		/// <param name="guards"></param>
		/// <param name="actionList"></param>
		/// <returns></returns>
		public static IMode CreateMode(IConfiguration config, IGuard[] guards, IActionList actionList)
		{
			switch (config.Mode)
			{
				case Mode.Normal:
					return new NormalMode(config, guards, actionList);
				case Mode.Interactive:
					return new InteractiveMode(config, guards, actionList);
			}
			return null;
		}

		/// <summary>
		/// Creates service mode.
		/// </summary>
		/// <param name="config"></param>
		/// <param name="guards"></param>
		/// <param name="actionList"></param>
		/// <returns></returns>
		public static IMode CreateServiceMode(IConfiguration config, IGuard[] guards, IActionList actionList)
		{
			return new NormalMode(config, guards, actionList);
		}
	}
}
